import axios from 'axios'
import Vue from 'vue'
const http = axios.create({
    timeout: 1000 * 30,
    headers: {
         'Content-Type': 'application/json; charset=utf-8'
    }
})
//请求拦截
http.interceptors.request.use(config => {
    config.headers['token'] = Vue.cookie.get('token')
    return config
}, error => {
    return Promise.reject(error)
})
//响应拦截
http.interceptors.response.use(response => {
    if(response.data && response.data.code === 1451){
        /*
        清除登陆信息
        clearLoginInfo()
        */
    }
    return response;
},error => {
    return Promise.reject(error);
})

export default http;